home *** CD-ROM | disk | FTP | other *** search
/ Chip: 2005 Utilities / CHIP Utilities 2005.7z / CHIP Utilities 2005.iso / images / freesco.igz / freesco.img / router / rc / rc_main < prev    next >
Encoding:
Text File  |  2003-05-20  |  3.0 KB  |  155 lines

  1. #!/bin/sh
  2. #
  3. # Start/stop/etc FREESCO in different modes. Called by mode command.
  4. # This script is responsible for order of executing of other rc_* scripts
  5.  
  6. . /etc/colors
  7. . /etc/system.cfg
  8. . /etc/live.cfg
  9. . /etc/music.cfg
  10.  
  11. fn3()    { cp /boot/etc/ppp/${1}.opt /etc/ppp/
  12.       echo "name    \"$LOGIN\"
  13.       " >>/etc/ppp/${1}.opt
  14. }
  15. fn2()    { sed -n /^ISPFILE=/P /etc/chat.pwd; }
  16. fn1()    { TMP=$ISPFILE
  17.     [ "$PPPTYPE" = o ] && TMP=PPPoE
  18.     [ "$PPPTYPE" = t ] && TMP=PPtP
  19.       echo "$CM$1 Freesco v$VERSION...$CG        Mode $CC $ROUTER $TMP$CW"
  20. }
  21. fn()   { if [ "$TIMADDR" ]; then
  22.         fork synctime
  23.      fi        
  24. }
  25. f_pkg()    { for i in `ls /pkg/rc/`; do [ -x /pkg/rc/$i ] && /pkg/rc/$i $1; done; }
  26. stp()    {
  27.     [ "`fn2`" ] || return
  28.     echo; fn1 Stopping
  29.     rc_mon $1
  30.     rc_user $1
  31.     f_pkg $1
  32.     rc_diald $1
  33.     rc_lease $1
  34.     rc_ras $1
  35.     killall pppd
  36.     rc_crond $1
  37.     rc_lpd $1
  38.     rc_ident $1
  39.     rc_dhcpd $1
  40.     rc_dns $1
  41.     rc_httpd $1
  42.     rc_ftpd $1
  43.     rc_tlnet $1
  44.     rc_masq $1
  45.     rc_eth $1
  46.     rc_bridg $1
  47.     rc_net $1
  48.     rc_pfwd $1
  49. }
  50. str()    {
  51.     : >/etc/chat.pwd
  52.     if [ "$2" ]; then
  53.         cat >/etc/live.cfg <<EOF
  54. ROUTER=$2
  55. BOOTMOD=$BOOTMOD
  56. VERSION=$VERSION
  57. BOOTDEV=$BOOTDEV
  58. BOOTIME="$BOOTIME"
  59. EOF
  60.         ROUTER=$2
  61.     fi    
  62.     if [ "$ROUTER" = dialup -o "$USEPPP0" = y ]; then
  63.         if [ "$3" ]; then
  64.             ISPFILE=$3
  65.         elif [ "$ROUTER" = ethernet ]; then
  66.             ISPFILE=ethernet    
  67.         else
  68.             set -- "`ls /etc/*.isp 2>/dev/null`"
  69.             ISPFILE=`basename "$1" .isp`
  70.             [ -f /etc/${DEFISP}.isp ] && ISPFILE=$DEFISP
  71.         fi
  72.         if [ -f /etc/${ISPFILE}.isp ]; then 
  73.             cat /etc/${ISPFILE}.isp > /etc/chat.pwd
  74.             eval `sed -n /PASSWD/P /etc/chat.pwd`
  75.             eval `sed -n /LOGIN/P /etc/chat.pwd`
  76.             echo "\"$LOGIN\"    *    \"$PASSWD\"
  77.             " >/etc/ppp/pap-secrets
  78.             chmod 600 /etc/ppp/pap-secrets
  79.             if [ "$ROUTER" = ethernet -a "$USEPPP0" = y ]; then
  80.                 [ "$PPPTYPE" = o ] && fn3 pppoe
  81.                 [ "$PPPTYPE" = t ] && fn3 pptp
  82.                 ISPFILE=ethernet
  83.             fi
  84.  
  85.         else 
  86.             echo "${CR}Warning ! No ISP account defined, please add one in advanced setup.$CW"
  87.         fi
  88.     fi
  89.     echo "ISPFILE=$ISPFILE" >>/etc/chat.pwd
  90.     fn1 Starting
  91.     set -- start
  92.     if [ "$ROUTER" = bridge ]; then
  93.         rc_bridg $1
  94.         exit
  95.     fi    
  96.     rc_net $1
  97.     rc_masq $1
  98.     rc_tlnet $1
  99.     rc_dns $1
  100.     rc_dhcpd $1
  101.     rc_httpd $1
  102.     rc_ftpd $1
  103.     rc_ident $1
  104.     rc_lpd $1
  105.     rc_crond $1
  106.     rc_ras $1
  107.     rc_eth $1
  108.     rc_lease $1
  109.     rc_diald $1
  110.     rc_pfwd $1
  111.     f_pkg $1
  112.     rc_user $1
  113.     rc_mon $1
  114.     if [ "$ROUTER" != dialup ]; then
  115.         fn
  116.         fork dyndns
  117.     fi    
  118. }
  119. case "$1" in
  120.     boot)    rm /etc/ppp/*.opt 2>/dev/null
  121.         for i in `ls boot/kbd/*.gz 2>/dev/null`; do
  122.             [ -f $i ] || break
  123.             echo -n "Loading keyboard map...            $CR"
  124.             zcat <$i | loadkmap
  125.             = $? "Done $CC `basename $i .gz`"
  126.             break
  127.         done
  128.         rc_pnp $1
  129.         rc_comm $1
  130.         f_pkg $1
  131.         rc_user $1;;
  132.     start)    str $1 $2 $3;;
  133.     stop|halt)stp stop;;
  134.     restart)stp stop; str start $2 $3;;
  135.     newip)    rc_eth $1
  136.         rc_masq $1
  137.         rc_dns $1
  138.         rc_pfwd $1
  139.         rc_dhcpd $1
  140.         rc_ras $1
  141.         fn2 $1
  142.         f_pkg $1
  143.         rc_user $1
  144.         fn
  145.         if [ "$ENABEEP" = y ]; then
  146.             play $NEWIP
  147.         fi    
  148.         fork dyndns
  149.         ;;
  150.     status)    for i in `ls /rc/* /pkg/rc/* 2>/dev/null`; do
  151.             [ -x $i -a "$i" != /rc/rc_main ] && $i status
  152.             echo
  153.         done;;
  154. esac
  155.